home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ussbc23.zip / DEMOS / REPORTFM.PAS < prev    next >
Pascal/Delphi Source File  |  1996-07-18  |  3KB  |  101 lines

  1. unit Reportfm;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, SSBC, StdCtrls, Quickrep, ExtCtrls, DB, DBTables, Qrssbc;
  8.  
  9. type
  10.   TfmReport = class(TForm)
  11.     QuickReport: TQuickReport;
  12.     tbCustomer: TTable;
  13.     dsCustomer: TDataSource;
  14.     bndDetail: TQRBand;
  15.     QRDBText1: TQRDBText;
  16.     QRDBText2: TQRDBText;
  17.     QRDBText3: TQRDBText;
  18.     QRDBText4: TQRDBText;
  19.     QRDBText5: TQRDBText;
  20.     QRDBText6: TQRDBText;
  21.     QRDBText7: TQRDBText;
  22.     tbCustomerCustNo: TFloatField;
  23.     tbCustomerCompany: TStringField;
  24.     tbCustomerAddr1: TStringField;
  25.     tbCustomerAddr2: TStringField;
  26.     tbCustomerCity: TStringField;
  27.     tbCustomerState: TStringField;
  28.     tbCustomerZip: TStringField;
  29.     tbCustomerCountry: TStringField;
  30.     tbCustomerPhone: TStringField;
  31.     tbCustomerFAX: TStringField;
  32.     tbCustomerTaxRate: TFloatField;
  33.     tbCustomerContact: TStringField;
  34.     tbCustomerLastInvoiceDate: TDateTimeField;
  35.     btReport: TButton;
  36.     SSBarcode1: TSSBarcode;
  37.     QRssBarcode1: TQRssBarcode;
  38.     procedure tbCustomerZipGetText(Sender: TField; var Text: OpenString;
  39.       DisplayText: Boolean);
  40.     procedure btReportClick(Sender: TObject);
  41.     procedure QuickReportFilter(var PrintRecord: Boolean);
  42.   private
  43.     { Private declarations }
  44.   public
  45.     { Public declarations }
  46.   end;
  47.  
  48. var
  49.   fmReport: TfmReport;
  50.  
  51. implementation
  52.  
  53. {$R *.DFM}
  54.  
  55. procedure TfmReport.tbCustomerZipGetText(Sender: TField;
  56.   var Text: OpenString; DisplayText: Boolean);
  57.  
  58. var
  59.   St : string;
  60.  
  61.  
  62.   function IsNumeric(St : string) : boolean;
  63.  
  64.   var
  65.     X   : integer;
  66.     AcceptSet : set of char;
  67.   begin
  68.     Result := true;
  69.     AcceptSet := ['0'..'9','-'];
  70.     for X := 1 to Length(St) do
  71.       if not (St[X] in AcceptSet) then
  72.         Result:= false;
  73.   end;
  74.  
  75. begin
  76.   { it is the programmer's responsibility to make sure, when an ssBarcode is linked to a
  77.     DataSource/DataField, that the values being passed to the barcode are legal for that
  78.     symbology.  In this case, we are using PostNet, which requires a numeric zip code.
  79.     Since the DBDEMOS:CUSTOMERS.DB file has some non-U.S. zip codes, we must write a
  80.     GetText handler to throw out any codes that aren't numeric. }
  81.  
  82.   St := Sender.AsString;
  83.   if (not IsNumeric(St)) or (not (Length(St) in [5,9,10,11])) then
  84.     Text := ''
  85.   else
  86.     Text := St;
  87.  
  88. end;
  89.  
  90. procedure TfmReport.btReportClick(Sender: TObject);
  91. begin
  92.   QuickReport.Preview;
  93. end;
  94.  
  95. procedure TfmReport.QuickReportFilter(var PrintRecord: Boolean);
  96. begin
  97.   PrintRecord := tbCustomer.FieldByName('ZIP').AsString <> '';
  98. end;
  99.  
  100. end.
  101.